/**
 * Project Name:fire-industry-DM-center
 * File Name:WebConfig.java
 * Package Name:com.firestone.config.mvc
 * Date:2018年3月22日上午10:37:09
 *
*/

package com.firestone.config.mvc;

import java.util.List;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @Description: TODO(web系统配置)
 * @author CAIYJ
 * @date 2018年3月22日 上午10:37:09
 */
@Configuration
@Order(0)
public class WebConfig extends WebMvcConfigurationSupport {

    @Bean
    public BCryptPasswordEncoder bCryptPasswordEncoder() {
        return new BCryptPasswordEncoder();
    }

    /**
     * 增加消息转换器，将返回消息中的 null 转成空字符串
     * 
     * @param converters
     */
    @Override
    protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        converters.add(new MessageConverter());
        super.configureMessageConverters(converters);
    }
    
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
}
